<%-- 
  -- Body New para Teacher.
  --
  -- @author ariel.piechotka
--%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<%@ taglib uri="/WEB-INF/struts-html-el-1.2.8.tld" prefix="html-el"%>
<%@ taglib uri="/WEB-INF/struts-logic-el-1.2.8.tld" prefix="logic-el"%>
<%@ taglib uri="/WEB-INF/security.tld" prefix="security" %>

<%@ taglib uri="http://struts.apache.org/tags-bean-el" prefix="bean2"%>

<script src="<html:rewrite page='/protected/script/util.js'/>" type="text/javascript"></script>

<%-- Para EXT --%>
<link rel="stylesheet" type="text/css" href="<html:rewrite page='/protected/script/ext-1.1.1/resources/css/ext-all.css'/>" />

<script src="<html:rewrite page='/protected/script/ext-1.1.1/adapter/ext/ext-base.js'/>" type="text/javascript"></script>
<script src="<html:rewrite page='/protected/script/ext-1.1.1/ext-all.js'/>" type="text/javascript"></script>

<script src="<html:rewrite page='/protected/script/calendar/calendar.js'/>" type="text/javascript"></script>
<script src="<html:rewrite page='/protected/script/calendar/calendar-setup.js'/>" type="text/javascript"></script>
<script src="<html:rewrite page='/protected/script/calendar/lang/calendar-es.js'/>" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="<html:rewrite page='/protected/script/calendar/style/calendar-blue.css'/>" id="styleFileAnyId"/>



<div class="errors">
    <html:errors />
</div>


<script type="text/javascript">
    /** Crea una docente */
    function createTeacher() {

        var nameValue = $("nameId").value;
        var bodyValue = $("bodyId").value;
        var fileNumberValue = $("fileNumberId").value;
        var cvValue = $("cvId").value;
        var degreeValue = $("degreeId").value;
        var personalIdValue = $("personalIdId").value;
        var taxIdValue = $("taxIdId").value;
        
        if (Util.valid.isBlank(nameValue)) {
            Ext.MessageBox.alert('Error', 'Debe ingresar el nombre. ');
            $("nameId").focus();
            return;
        }
        if (Util.valid.isBlank(fileNumberValue)) {
            Ext.MessageBox.alert('Error', 'Debe ingresar el legajo. ');
            $("fileNumberId").focus();
            return;
        }
        if (Util.valid.isBlank(cvValue)) {
            Ext.MessageBox.alert('Error', 'Debe ingresar el curriculum. ');
            $("cvId").focus();
            return;
        }
        if (Util.valid.isBlank(degreeValue)) {
            Ext.MessageBox.alert('Error', 'Debe ingresar el t&iacute;tulo. ');
            $("degreeId").focus();
            return;
        }
        if (Util.valid.isBlank(personalIdValue)) {
            Ext.MessageBox.alert('Error', 'Debe ingresar el n&uacute;mero de documento. ');
            $("personalIdId").focus();
            return;
        }
        if (Util.valid.isBlank(taxIdValue)) {
            Ext.MessageBox.alert('Error', 'Debe ingresar el CUIL/CUIT. ');
            $("taxIdId").focus();
            return;
        }
        
        var nameObj = $("nameConfirmId");
        var bodyObj = $("bodyConfirmId");
        var fileNumberObj = $("fileNumberConfirmId");
        var cvObj = $("cvConfirmId");
        var degreeObj = $("degreeConfirmId");
        var personalIdObj = $("personalIdConfirmId");
        var taxIdObj = $("taxIdConfirmId");
        
        nameObj.value = nameValue;
        bodyObj.value = bodyValue;
        fileNumberObj.value = fileNumberValue;
        cvObj.value = cvValue;
        degreeObj.value = degreeValue;
        personalIdObj.value = personalIdValue;
        taxIdObj.value = taxIdValue;
        
        var form = $("createTeacherFormId");
        form.submit();
    } 
    
</script>

<%-- El ID del form NO debe ser modificado. Se usa desde el menu --%>
<html:form action="/protected/showNewTeacher" styleId="teacherFormId">

    <h2>Creaci&oacute;n de docente</h2>
    
    <div class="teacherEdit">
        <table class="tableData" cellspacing="0">
            <tr>
                <td class="tableDataTitle">
                    Legajo*
                </td>
                <td class="tableDataValue">
                    <html:text property="fileNumber" name="teacherForm" styleId="fileNumberId" alt="Legajo del docente" maxlength="10" />
                </td>            
            </tr>
            <tr>
                <td class="tableDataTitle">
                    Nombre*
                </td>
                <td class="tableDataValue">
                    <html:text property="name" name="teacherForm" styleId="nameId" alt="Nombre del docente" maxlength="100"/>
                </td>            
            </tr>
            <tr>
                <td class="tableDataTitle">
                    N&ordm; de documento*
                </td>
                <td class="tableDataValue">
                    <html:text property="personalId" name="teacherForm" styleId="personalIdId" alt="Numero de documento" maxlength="25"/>
                </td>            
            </tr>
            <tr>
                <td class="tableDataTitle">
                    CUIT/CUIL*
                </td>
                <td class="tableDataValue">
                    <html:text property="taxId" name="teacherForm" styleId="taxIdId" alt="CUIL o CUIT" maxlength="14"/>
                </td>            
            </tr>
            <tr>
                <td class="tableDataTitle">
                    Ente*
                </td>
                <td class="tableDataValue">
                    <html:select property="idBody" styleClass="allSelects" styleId="bodyId" >
                        <html:optionsCollection property="bodyOptions"/>
                    </html:select>
                </td>            
            </tr>
            <tr>
                <td class="tableDataTitle">
                    T&iacute;tulo*
                </td>
                <td class="tableDataValue">
                    <html:text property="degree" name="teacherForm" styleId="degreeId" alt="Titulo del docente" maxlength="150"/>
                </td>            
            </tr>
            <tr>
                <td class="tableDataTitle">
                    Curriculum*
                </td>
                <td class="tableDataValue">
                    <html:textarea property="cv" name="teacherForm" styleId="cvId" alt="Curriculum vitae" cols="40" rows="15"/>
                </td>
            </tr>
        </table>
        
        <br/>
        <div id="clear"></div>
    	<p class="mensajeCamposObligatorios">Los campos marcados con un asterisco (*) son obligatorios.</p>
    	<div id="clear"></div>

        <div id="clear">
        </div>
        <div id="clear">
        </div>
        
        <%-- No se valida seguridad ya que SOLO entran aca los q tienen permiso --%>
        <div class="panelButton">
            <input type="button" value="Guardar" onclick="createTeacher();" title="Guarda el docente..." class="button">
        </div>  
    
    </div>

</html:form>

<%-- Inyectados por Javascript --%>
<div id="createDivId" class="hideClass">
    <html:form action="/protected/createTeacher" styleId="createTeacherFormId">
        <html:hidden property="name" value="" styleId="nameConfirmId" />
        <html:hidden property="idBody" value="" styleId="bodyConfirmId" />
        <html:hidden property="fileNumber" value="" styleId="fileNumberConfirmId" />
        <html:hidden property="cv" value="" styleId="cvConfirmId" />
        <html:hidden property="degree" value="" styleId="degreeConfirmId" />
        <html:hidden property="personalId" value="" styleId="personalIdConfirmId" />
        <html:hidden property="taxId" value="" styleId="taxIdConfirmId" />
    </html:form>
</div>
